<?php

namespace app\rental\model;

use think\Model;

class RentalPriceRangeModel extends Model
{
    public static   $STATUS = array(
        1=>"已启用",
        0=>"未启用",
    );
    public function getPriceRangeAttr($value,$data)
    {
        if(empty($data['min_price'])){
                $price_range= $data['max_price'].'万以下';
        }
        if($data['min_price']<10&&!empty($data['min_price'])&&!empty($data['max_price'])){
                $price_range= '0'.$data['min_price'].'万-'.$data['max_price'].'万';
        }
        if($data['min_price']>=10&&!empty($data['min_price'])&&!empty($data['max_price'])){
                $price_range= $data['min_price'].'万-'.$data['max_price'].'万';
        }
        if(empty($data['max_price'])){
            $price_range= $data['min_price'].'万以上';
        }
        return $price_range;
    }
        /**
     * 关联汽车
     */
    public function cars()
    {
        return $this->hasMany('RentalCarModel','price_range_id');
    }
    public function getPriceRange(){
       return $this->order('min_price', 'asc')->select();
    }
}
